﻿namespace Sustainalytics.Utils
{
    /// <summary>
    /// Handle arguments passed to logging mechanism (EventSource).
    /// </summary>
    public static class LogArgument
    {
        /// <summary>
        /// Convert argument to string.
        /// </summary>
        /// <param name="arg"> Argument. </param>
        /// <returns> Argument as string. </returns>
        public static string GetString(object arg)
        {
            if (arg == null)
            {
                return null;
            }
            else
            {
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(arg);
                return json;
            }
        }
    }
}
